﻿using System;
using System.Text;
using System.Windows.Browser;

namespace MapServiceAPI
{
    public sealed class MapServiceJS
    {
        private static readonly MapServiceJS instance = new MapServiceJS();
        private MapServiceJS() { }
        public static MapServiceJS Instance
        {
            get { return instance; }
        }
        private IMapServiceJS mapService = new GoogleMapJS();

        public void SetService(IMapServiceJS mapService)
        {
            this.mapService = mapService;
        }
        private string silverlightControlID = "silverlightControl";

        public string SilverlightControlID
        {
            get { return silverlightControlID; }
            set { silverlightControlID = value; }
        }
 
        public void MapInit(Map mapJsObj)
        {
            mapService.MapInit(mapJsObj, silverlightControlID);
        }
        public void MapSetStyle(MapStyle style, Map mapJsObj)
        {
            mapService.MapSetStyle(style, mapJsObj);
        }
        public void MapSetCenterZoom(LatLng center, Int32 zoom, Map mapJsObj)
        {
            mapService.MapSetCenterZoom(center, zoom, mapJsObj);
        }
        public void MapAddShape(MapShapes shape, Map mapJsObj)
        {
            mapService.MapAddShape(shape, mapJsObj);
        }
        public void MapDeleteShape(MapShapes shape, Map mapJsObj)
        {
            mapService.MapDeleteShape(shape, mapJsObj);
        }
        public void MapUnload()
        {
            mapService.MapUnload();
        }
        public void ShapeMarker(MapShapes shape, LatLng point, String title, String iconSource)
        {
            mapService.ShapeMarker(shape, point, title, iconSource, silverlightControlID);
        }
        public void ShapeMarkerSetPoint(MapShapes shape, LatLng point)
        {
            mapService.ShapeMarkerSetPoint(shape, point);
        }
        public void ShapePolyLine(MapShapes shape, LatLng[] points, System.Windows.Media.Color color, Int32 weight, Double opacity)
        {
            mapService.ShapePolyLine(shape, points, color, weight, opacity, silverlightControlID);
        }
        public void ShapePolygon(MapShapes shape, LatLng[] points, System.Windows.Media.Color color, Int32 weight, Double opacity, System.Windows.Media.Color fillColor, double fillOpacity)
        {
            mapService.ShapePolygon(shape, points, color, weight, opacity, fillColor, fillOpacity, silverlightControlID);
        }
        public void ShapeDispose(MapShapes shape)
        {
            mapService.ShapeDispose(shape);
        }
    }
    public enum MapServiceType
    {
        Google,
        VirtualEarth
    };
}
